package com.testfileupload.uploadimg.design.builder.car.model;

import java.util.ArrayList;

public abstract class CarModel {
    //定义基本方法的执行顺序
    private ArrayList<String> sequence = new ArrayList<>();

    protected abstract void start();

    protected abstract void stop();

    protected abstract void alerm();

    protected abstract void engineBoom();

    final public void run() {
        for (String s : sequence) {
            if ("start".equals(s)) {
                this.start();
            } else if ("stop".equals(s)) {
                this.stop();
            } else if ("alerm".equals(s)) {
                this.alerm();
            } else if ("engineBoom".equals(s)) {
                this.engineBoom();
            }
        }
    }

    //把值传递到类内
    public void setSequence(ArrayList<String> sequence) {
        this.sequence = sequence;
    }
}
